﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TuiHuiGF.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.ZhangWuGL.TuiHuiGF" Theme="Default"%>

<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title> 
    <script src="../../../JS/jquery.js" type="text/javascript"></script>
    <script src="../../../JS/AddEditCancel.js" type="text/javascript"></script>
    <script type="text/javascript">
        //取消内部转账
        function qxnbzz() {
            if (confirm("确定取消内部转账吗？")) {
                hdCollection.Set("yhh", gvGrid.GetRowKey(gvGrid.GetFocusedRowIndex()));
                hdCollection.Set("ym", "11");
                ASPxCallback1.PerformCallback("qxnbzz");
            }

        }

        var r_out = -1, r_in = -1;
        var bh_out = 0, bh_in = 0;
        function qdClick() {
            if (txtYongHuM_out2.GetText() == "" && txtYingShouJE_out2.GetText() == "" && txtShiShouJE_out2.GetText() == "") {
                Validate1();
            }
            else {
                if (txtYongHuM_in2.GetText() == "" && txtYingShouJE_in2.GetText() == "" && txtShiShouJE_in2.GetText() == "") {
                    Validate2();
                }
                else {
                    queding();
                }
            }

        }

        function queding() {
            //alert(r_out+" "+r_in);
            if (r_out == "1" && r_in == "1") {
                if (txtZhuanZhangJE.GetText() == "") {
                    alert("请先输入转账金额！");
                }
                else {
                    if (parseFloat(txtZhuanZhangJE.GetText()) > parseFloat(txtShiShouJE_out2.GetText())) {
                        alert("转账金额不能大于实收金额");
                    }
                    else {
                        hdCollection.Set("yhh", bh_out);
                        hdCollection.Set("ym", bh_in);
                        ASPxCallback1.PerformCallback("qdzz");
                        btnQueDing.SetEnabled(false);
                    }
                }

            }
        }

        //转出费用信息验证
        function Validate1() {
            if (txtYongHuH_out2.GetText() == "" || txtShuiLiangNY_out2.GetText() == "") {
                alert("转出费用信息用户号、水量年月为空，请先输入！");
            }
            else {
                //debugger;
                //先验证是否有加价开账记录
                //转出费用信息
                var yhh_out = txtYongHuH_out2.GetText();
                var ym_out = txtShuiLiangNY_out2.GetText();
                hdCollection.Set("yhh", yhh_out);
                hdCollection.Set("ym", ym_out);
                ASPxCallback1.PerformCallback("setinfo_out");
            }
        }

        //转入费用信息验证
        function Validate2() {
            if (txtYongHuH_in2.GetText() == "" || txtShuiLiangNY_in2.GetText() == "") {
                alert("转入费用信息用户号、水量年月为空，请先输入！");
            }
            else {
                //转入费用信息
                var yhh_in = txtYongHuH_in2.GetText();
                var ym_in = txtShuiLiangNY_in2.GetText();
                hdCollection.Set("yhh", yhh_in);
                hdCollection.Set("ym", ym_in);
                ASPxCallback1.PerformCallback("setinfo_in");
            }
        }

        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            if (type == "setinfo_out") {
                var result = arr[2];
                if (result == "1") {
                    txtYongHuM_out2.SetText(arr[3]);
                    txtYingShouJE_out2.SetText(arr[4]);
                    txtShiShouJE_out2.SetText(arr[5]);
                    r_out = arr[6];
                    bh_out = arr[7];
                }
                else {
                    alert("您输入的转出费用信息没有找到加价开账记录");
                }
            }
            if (type == "setinfo_in") {
                var result = arr[2];
                if (result == "1") {
                    txtYongHuM_in2.SetText(arr[3]);
                    txtYingShouJE_in2.SetText(arr[4]);
                    txtShiShouJE_in2.SetText(arr[5]);
                    r_in = arr[6];
                    bh_in = arr[7];
                }
                else {
                    alert("您输入的转入费用信息没有找到加价开账记录");
                }
            }
            if (type == "qdzz") {
                if (arr[2] == "1") {
                    alert("确认转账成功");
                    txtShiShouJE_out2.SetText(parseFloat(txtShiShouJE_out2.GetText()) - parseFloat(txtZhuanZhangJE.GetText()));
                    txtShiShouJE_in2.SetText(parseFloat(txtShiShouJE_in2.GetText()) + parseFloat(txtZhuanZhangJE.GetText()));
                }
                else {
                    alert("转账失败");
                }
            }
            if (type == "qxnbzz") {
                if (arr[2] == "1") {
                    alert("取消内部转账成功");
                    gvGrid.PerformCallback();
                }
                else {
                    alert("取消失败");
                }
            }

        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            退回灌费
        </div>
        <div style="display: none;">
            <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
            <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        </div>
        <div>
            <div>
                <table>
                    <tr>
                        <td>账务年月：</td>
                        <td>
                            <dx:ASPxTextBox runat="server" ID="txtZWNY" ClientEnabled="false" Width="80%"></dx:ASPxTextBox>
                        </td>
                    </tr>
                </table>
            </div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" Width="98%" Height="535px" AutoPostBack="true">
                        <TabPages>
                            <dx:TabPage Text="退回灌费">
                                <ContentCollection>
                                    <dx:ContentControl Height="800px">
                                        <div style="width: 100%;">
                                            <div style="width: 50%; margin-left: 30%;">
                                                <table style="text-align: right; height: 270px; width: 100%;">
                                                    <tr>
                                                        <td style="width: 30%;">
                                                            <dx:ASPxRadioButton runat="server" ID="rdbYHH" GroupName="1" ClientInstanceName="rdbYHH" Checked="true" Text="按用户号查询"></dx:ASPxRadioButton>
                                                        </td>
                                                        <td style="width: 60%;">
                                                            <dx:ASPxRadioButton runat="server" ID="rdbBMH" GroupName="1" ClientInstanceName="rdbBMH" Checked="true" Text="按部门号查询"></dx:ASPxRadioButton>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 20%;"><span style="font-size: 12px;">编号：</span></td>
                                                        <td>
                                                            <dx:ASPxTextBox ID="txtBianHao" Width="60%" runat="server" ClientEnabled="true" ClientInstanceName="txtBianHao">
                                                                <ClientSideEvents KeyUp="function(s,e){inputNum(s);}" KeyPress="function(s,e){if (event.keyCode == 13) {$('#ASPxPageControl1_txtShuiLiangNY_out2_I').focus(); };}" />
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                        <td></td>
                                                    </tr>
                                                    <tr>
                                                        <td><span style="font-size: 12px;">水量年月：</span></td>
                                                        <td>
                                                            <dx:ASPxTextBox ID="txtShuiLiangNY" Width="60%" runat="server" ClientEnabled="true" ClientInstanceName="txtShuiLiangNY">
                                                                <ClientSideEvents KeyUp="function(s,e){inputNum(s);}" KeyPress="function(s,e){if (event.keyCode == 13) { Validate1(); };}" />
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><span style="font-size: 12px;">费用类型：</span></td>
                                                        <td>
                                                            <dx:ASPxComboBox ID="cmbFeiYongLX" ClientInstanceName="cmbFeiYongLX" runat="server" ClientEnabled="false" Width="60%">
                                                                <Items>
                                                                    <dx:ListEditItem Text="=" Value="1" />
                                                                    <dx:ListEditItem Text=">" Value="2" />
                                                                    <dx:ListEditItem Text=">=" Value="3" />
                                                                    <dx:ListEditItem Text="<" Value="4" />
                                                                    <dx:ListEditItem Text="<=" Value="5" />
                                                                    <dx:ListEditItem Text="<>" Value="6" />
                                                                </Items>
                                                            </dx:ASPxComboBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><span style="font-size: 12px;">名称：</span></td>
                                                        <td>
                                                            <dx:ASPxTextBox ID="txtMingCheng" Width="100%" runat="server" ClientEnabled="false" ClientInstanceName="txtMingCheng">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><span style="font-size: 12px;">开帐日期：</span></td>
                                                        <td>
                                                            <dx:ASPxDateEdit runat="server" ID="deKaiZhangRQ" ClientInstanceName="deKaiZhangRQ" ClientEnabled="false">
                                                                <CalendarProperties ClearButtonText="清除" TodayButtonText="今天"></CalendarProperties>
                                                            </dx:ASPxDateEdit>
                                                        </td>
                                                        <td></td>
                                                    </tr>
                                                    <tr>
                                                        <td><span style="font-size: 12px;">应退金额：</span></td>
                                                        <td>
                                                            <dx:ASPxTextBox ID="txtYingTuiJE" Width="60%" runat="server" ClientEnabled="false" ClientInstanceName="txtYingTuiJE">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><span style="font-size: 12px;">退款金额：</span></td>
                                                        <td>
                                                            <dx:ASPxTextBox ID="txtTuiKuanJE" Width="60%" runat="server" ClientEnabled="false" ClientInstanceName="txtTuiKuanJE">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                        <dx:ASPxButton ID="btnQueDing" runat="server" Text="确定" ClientInstanceName="btnQueDing" UseSubmitBehavior="false" AutoPostBack="false">
                                                            <ClientSideEvents Click="function(s,e){qdClick();}" />
                                                        </dx:ASPxButton>&nbsp;&nbsp;&nbsp;&nbsp;
                                                        </td>
                                                        <td style="text-align:left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                        <dx:ASPxButton ID="btnChaXun" runat="server" Text="查询" ClientInstanceName="btnChaXun" UseSubmitBehavior="false" AutoPostBack="false">
                                                            <ClientSideEvents Click="function(s,e){qdClick();}" />
                                                        </dx:ASPxButton>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </div>
                                    </dx:ContentControl>
                                </ContentCollection>
                            </dx:TabPage>
                            <dx:TabPage Text="取消退回灌费">
                                <ContentCollection>
                                    <dx:ContentControl>
                                         <div>
                                            <dx:ASPxGridView ID="gvGrid" ClientInstanceName="gvGrid" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" 
                                                EnableCallBacks="false"   Width="100%" OnCustomCallback="gvGrid_CustomCallback" OnFocusedRowChanged="gvGrid_FocusedRowChanged">
                                                <Columns>
                                                    <dx:GridViewDataTextColumn FieldName="" Caption="用户（部门）号" Width="20%" >
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="" Caption="用户（部门）名" Width="20%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="" Caption="水量年月" Width="20%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="" Caption="费用类型" Width="20%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="" Caption="退款金额" Width="20%">
                                                    </dx:GridViewDataTextColumn>
                                                </Columns>
                                                <Settings VerticalScrollBarMode="Visible" VerticalScrollableHeight="400" HorizontalScrollBarMode="Auto" />
                                                <SettingsPager Mode="EndlessPaging" PageSize="100" AlwaysShowPager="true" FirstPageButton-Visible="true" />
                                                <Settings ShowFooter="True" />
                                                <SettingsBehavior AllowFocusedRow="True"  ColumnResizeMode="Control" />
                                                <SettingsBehavior ProcessFocusedRowChangedOnServer="true" />
                                                <%--<Settings VerticalScrollableHeight="200" VerticalScrollBarMode="Auto" HorizontalScrollBarMode="Auto" />
                                                <SettingsBehavior ProcessFocusedRowChangedOnServer="true" />--%>
                                            </dx:ASPxGridView>
                                        </div>
                                        <br />

                                        <div>
                                            <table align="right">
                                                <tr>
                                                    <td>
                                                        <dx:ASPxButton ID="btnQuXiaoTK" runat="server" Text="取消退款" AutoPostBack="false"  UseSubmitBehavior="false">
                                                            <ClientSideEvents  Click="function(s,e){qxnbzz();}"/>
                                                        </dx:ASPxButton>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </dx:ContentControl>
                                </ContentCollection>
                            </dx:TabPage>
                        </TabPages>
                    </dx:ASPxPageControl>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>

